package com.example.ceramics.data;

import com.example.ceramics.R;
import com.example.ceramics.entity.GoodsEntity;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Datas {
    private List<List<String>> Names = new ArrayList<>();
    private List<List<Double>> Prices = new ArrayList<>();
    private List<List<String>> Signatures = new ArrayList<>();
    private List<List<Integer>> Imgs = new ArrayList<>();

    private List<String> names1;
    private List<String> names2;
    private List<String> names3;
    private List<String> names4;
    private List<String> names5;
    private List<String> names6;
    private List<String> names7;
    private List<String> names8;

    private List<Double> prices1;
    private List<Double> prices2;
    private List<Double> prices3;
    private List<Double> prices4;
    private List<Double> prices5;
    private List<Double> prices6;
    private List<Double> prices7;
    private List<Double> prices8;

    private List<String> signatures1;
    private List<String> signatures2;
    private List<String> signatures3;
    private List<String> signatures4;
    private List<String> signatures5;
    private List<String> signatures6;
    private List<String> signatures7;
    private List<String> signatures8;

    private List<Integer> imgs1;
    private List<Integer> imgs2;
    private List<Integer> imgs3;
    private List<Integer> imgs4;
    private List<Integer> imgs5;
    private List<Integer> imgs6;
    private List<Integer> imgs7;
    private List<Integer> imgs8;

    private List<String> type;

//    private boolean flag=false;

    public void setDatas(){
//        if(flag){
//            return;
//        }
//        flag=true;
        //类型
        type = new ArrayList<>();
        Collections.addAll(type,"十二生肖系列","阴阳五行系列","四季系列","百鸟朝凤系列","地域风采系列","节日限定","其他周边","定制服务");

        //十二生肖系列
        names1 = new ArrayList<>();
        Collections.addAll(names1, "ab没有", "b", "c", "d");
        prices1 = new ArrayList<>();
        Collections.addAll(prices1, 1.0, 2.0, 3.0, 4.0);
        signatures1 = new ArrayList<>();
        Collections.addAll(signatures1, "1.0", "2.0", "3.0", "4.0");
        imgs1 = new ArrayList<>();
        Collections.addAll(imgs1, R.mipmap.image1, R.mipmap.image1, R.mipmap.image1, R.mipmap.image1);

        //阴阳五行系列
        names2 = new ArrayList<>();
        Collections.addAll(names2, "a", "b", "c", "d");
        prices2 = new ArrayList<>();
        Collections.addAll(prices2, 1.0, 2.0, 3.0, 4.0);
        signatures2 = new ArrayList<>();
        Collections.addAll(signatures2, "1.0", "2.0", "3.0", "4.0");
        imgs2 = new ArrayList<>();
        Collections.addAll(imgs2, R.mipmap.image2, R.mipmap.image2, R.mipmap.image2, R.mipmap.image2);

        //四季系列
        names3 = new ArrayList<>();
        Collections.addAll(names3, "a", "b", "c", "d");
        prices3 = new ArrayList<>();
        Collections.addAll(prices3, 1.0, 2.0, 3.0, 4.0);
        signatures3 = new ArrayList<>();
        Collections.addAll(signatures3, "1.0", "2.0", "3.0", "4.0");
        imgs3 = new ArrayList<>();
        Collections.addAll(imgs3, R.mipmap.image3, R.mipmap.image3, R.mipmap.image3, R.mipmap.image3);

        //百鸟朝凤系列
        names4 = new ArrayList<>();
        Collections.addAll(names4, "a", "b", "c", "d");
        prices4 = new ArrayList<>();
        Collections.addAll(prices4, 1.0, 2.0, 3.0, 4.0);
        signatures4 = new ArrayList<>();
        Collections.addAll(signatures4, "1.0", "2.0", "3.0", "4.0");
        imgs4 = new ArrayList<>();
        Collections.addAll(imgs4, R.mipmap.image1, R.mipmap.image1, R.mipmap.image1, R.mipmap.image1);

        //地域风采系列
        names5 = new ArrayList<>();
        Collections.addAll(names5, "a", "b", "c", "d");
        prices5 = new ArrayList<>();
        Collections.addAll(prices5, 1.0, 2.0, 3.0, 4.0);
        signatures5 = new ArrayList<>();
        Collections.addAll(signatures5, "1.0", "2.0", "3.0", "4.0");
        imgs5 = new ArrayList<>();
        Collections.addAll(imgs5, R.mipmap.image2, R.mipmap.image2, R.mipmap.image2, R.mipmap.image2);

        //节日限定
        names6 = new ArrayList<>();
        Collections.addAll(names6, "a", "b", "c", "d");
        prices6 = new ArrayList<>();
        Collections.addAll(prices6, 1.0, 2.0, 3.0, 4.0);
        signatures6 = new ArrayList<>();
        Collections.addAll(signatures6, "1.0", "2.0", "3.0", "4.0");
        imgs6 = new ArrayList<>();
        Collections.addAll(imgs6, R.mipmap.image3, R.mipmap.image3, R.mipmap.image3, R.mipmap.image3);

        //其他周边
        names7 = new ArrayList<>();
        Collections.addAll(names7, "a", "b", "c", "d");
        prices7 = new ArrayList<>();
        Collections.addAll(prices7, 1.0, 2.0, 3.0, 4.0);
        signatures7 = new ArrayList<>();
        Collections.addAll(signatures7, "1.0", "2.0", "3.0", "4.0");
        imgs7 = new ArrayList<>();
        Collections.addAll(imgs7, R.mipmap.image1, R.mipmap.image1, R.mipmap.image1, R.mipmap.image1);

        //定制服务
        names8 = new ArrayList<>();
        Collections.addAll(names8, "a", "b", "c", "d");
        prices8 = new ArrayList<>();
        Collections.addAll(prices8, 1.0, 2.0, 3.0, 4.0);
        signatures8 = new ArrayList<>();
        Collections.addAll(signatures8, "1.0", "2.0", "3.0", "4.0");
        imgs8 = new ArrayList<>();
        Collections.addAll(imgs8, R.mipmap.image2, R.mipmap.image2, R.mipmap.image2, R.mipmap.image2);

        Collections.addAll(Names,names1,names2,names3,names4,names5,names6,names7,names8);
        Collections.addAll(Prices,prices1,prices2,prices3,prices4,prices5,prices6,prices7,prices8);
        Collections.addAll(Signatures,signatures1,signatures2,signatures3,signatures4,signatures5,signatures6,signatures7,signatures8);
        Collections.addAll(Imgs,imgs1,imgs2,imgs3,imgs4,imgs5,imgs6,imgs7,imgs8);
    }

    public List<List<String>> getNames() {
        return Names;
    }

    public void setNames(List<List<String>> names) {
        Names = names;
    }

    public List<List<Double>> getPrices() {
        return Prices;
    }

    public void setPrices(List<List<Double>> prices) {
        Prices = prices;
    }

    public List<List<String>> getSignatures() {
        return Signatures;
    }

    public void setSignatures(List<List<String>> signatures) {
        Signatures = signatures;
    }

    public List<List<Integer>> getImgs() {
        return Imgs;
    }

    public void setImgs(List<List<Integer>> imgs) {
        Imgs = imgs;
    }

    public List<String> getType() {
        return type;
    }

    public void setType(List<String> type) {
        this.type = type;
    }

    public List<GoodsEntity> search(String searchWord) {
        List<GoodsEntity> searchGoods = new ArrayList<>();
        for (int i = 0; i < Names.size(); i++) {
            List<String> names = Names.get(i);
            for (int j = 0; j < names.size(); j++) {
                String name = names.get(j);
                if(name.contains(searchWord)){
                    GoodsEntity goodsEntity = new GoodsEntity();
                    goodsEntity.setGoodsName(name);
                    goodsEntity.setGoodsPrice(Prices.get(i).get(j));
                    goodsEntity.setGoodsSignature(Signatures.get(i).get(j));
                    goodsEntity.setGoodsImg(Imgs.get(i).get(j));
                    goodsEntity.setGoodsType(type.get(i));
                    searchGoods.add(goodsEntity);
                }
            }
        }
        return searchGoods;
    }
}
